package com.tj.collection.db.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.tj.collection.db.dao.ClPhoneRecordDao;
import com.tj.collection.db.entity.ClPhoneRecordEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: Karl
 * Date: 2019-12-25
 * Time: 11:19:45.686
 */

@Repository
public class ClPhoneRecordDaoImpl extends AbstractBaseMapper<ClPhoneRecordEntity> implements ClPhoneRecordDao {

    @Override
    public List<ClPhoneRecordEntity> selectPhoneRecordListByParams(Map<String, Object> params) {
        if (!params.containsKey("deleted")) {
            params.put("deleted", 0);
        }
        return getSqlSession().selectList(this.getStatement("selectByParams"), params);
    }

    @Override
    public List<ClPhoneRecordEntity> selectCommonByCollectionNo(String collectionNo) {
        Map<String, Object> params = new HashMap<>();
        params.put("collectionNo", collectionNo);
        return this.selectPhoneRecordListByParams(params);
    }

    /**
     * 查询不同手机号的最后一条记录
     *
     * @param collectionNo
     * @return
     */
    @Override
    public List<ClPhoneRecordEntity> selectLatestPhoneRecordByCollectionNo(String collectionNo) {
        Map<String, Object> params = new HashMap<>();
        params.put("collectionNo", collectionNo);
        return getSqlSession().selectList(this.getStatement("selectLatestPhoneRecordByCollectionNo"), params);
    }
}